<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>14-属性描述符</title>
</head>
<body>
    <script>
        // 给全局对象 window 对象，动态添加了一个属性
        var a = 1;
        console.log(window.a);  // 1
 
        // 写法2
        window.b = 2;
        // 声明写法可以省略
        b = 2;
        console.log(window.b);  //2

        delete window.a;
        // 删除失败：why？
        console.log(window.a); // 1

        // 获取对象的属性描述
        console.log(Object.getOwnPropertyDescriptor(window,'a'));
        /* 
            configurable: false (允许删除/编辑)
            enumerable: true    (可枚举)(for-in)
            value: 1            (值)
            writable: true      (可写)
        */

    </script>
</body>
</html>